package com.amumu.drama.common.modules.service.impl.payment.handler;

import com.amumu.drama.common.constant.OperateTypeEnum;
import com.amumu.drama.common.constant.PayStatusEnum;
import com.amumu.drama.common.modules.order.dto.OmsOrderDetail;
import com.amumu.drama.common.modules.order.dto.PrePayCreateDTO;
import com.amumu.drama.common.modules.order.dto.PrePayInfoDTO;
import com.amumu.drama.common.modules.service.impl.payment.PaymentFactory;
import com.amumu.drama.common.modules.service.impl.payment.PaymentReq;
import com.amumu.drama.common.modules.service.impl.payment.PaymentResp;
import com.amumu.drama.model.OmsOrder;

import java.util.Map;

public interface PaymentHandler {

    String[] type();


    default String getPayMethod(OmsOrder order) {
        return PaymentFactory.getPayHandlerType(order);
    }

    /** 预支付 */
    @Deprecated
    default PrePayInfoDTO prePay(PrePayCreateDTO prePayCreateDTO) {
        PrePayInfoDTO resp = new PrePayInfoDTO();
        resp.setStatus(true);
        resp.setTimeStamp(System.currentTimeMillis());
        return resp;
    }

    PaymentResp pay(PaymentReq param);


    /** 查询订单的支付状态 */
    default PaymentResp queryPayStatus(OmsOrderDetail orderDetail) {
        PaymentResp resp = new PaymentResp();
        resp.setPayStatusEnum(PayStatusEnum.getByCode(orderDetail.getPayStatus()));
        return resp;
    }

    /** 支付回调通知 */
    default PaymentResp payNotify(Map<String, String> params, String body) {
        return null;
    }


    default PaymentResp refund(PaymentReq param, OperateTypeEnum operateTypeEnum, Long operatorId) {
        return null;
    }

    /** 退款回调通知 */
    default PaymentResp refundNotify(Map<String, String> params, String body) {
        return null;
    }

    /** 查询订单的退款状态 */
    default PaymentResp queryRefundStatus(OmsOrder omsOrder) {
        PaymentResp resp = new PaymentResp();
        resp.setPayStatusEnum(PayStatusEnum.getByCode(omsOrder.getPayStatus()));
        return resp;
    }
}
